<template>
  <div>
    <common-head title="确认订单"></common-head>
    <div class="wrap">
      <van-contact-card
      :type="cardType"
      :name="order.contact.name"
      :tel="order.contact.tel"
      @click="choseContact"
      />
      <!-- 订单商品 -->
      <div class="items">
        <van-card
          v-for="item in order.items"
          :key="item.id"
          :num="item.num"
          :price="item.minPrice"
          :title="item.name"
          :thumb="item.pic"
        />
      </div>
      <!-- /订单商品 -->
    </div>
    <van-submit-bar
      :price="order.price*100"
      button-text="提交订单"
      @submit="onSubmit"
    />
  </div>
</template>

<script>
import CommonHead from '@components/CommonHead'
import { mapState } from 'vuex'
export default {
  data () {
    return {
    }
  },
  components: {
    CommonHead
  },
  methods: {
    choseContact () {
      if (this.cardType === 'add') {
        this.$router.push('/addContact')
      } else {
        this.$router.push('/addressLists')
      }
    },
    onSubmit () {
      alert(1)
    }
  },
  computed: {
    cardType () {
      if (this.order.contact.name) {
        return 'edit'
      } else {
        return 'add'
      }
    },
    ...mapState({
      order: (state) => state.order.nowOrder
    })
  }
}
</script>

<style lang="scss" scoped>

</style>
